package org.robotlegs.mvcs
{
	import flash.events.IEventDispatcher;
	
	import starling.events.EventDispatcher;

	/**
	 * 添加view监听的方法
	 * @author Elendil
	 * 
	 */
	public class FixedStarlingMediator extends StarlingMediator
	{
		public function FixedStarlingMediator()
		{
			super();
		}
		
		override protected function addViewListener(type:String, listener:Function, eventClass:Class=null, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=true):void
		{
			if (viewComponent is IEventDispatcher)
				super.addViewListener(type, listener, eventClass, useCapture, priority, useWeakReference);
			else if (viewComponent is EventDispatcher)
				EventDispatcher(viewComponent).addEventListener(type, listener);
		}
		
		override public function onRemove():void
		{
			if (viewComponent is EventDispatcher)
				EventDispatcher(viewComponent).removeEventListeners();
			cleanUp();
		}
		
		protected function cleanUp():void
		{
			
		}
	}
}